﻿#include "cocos2d.h"
#include "gametemplate.h"

#include "charactertemplate.h"
#include "animationtemplate.h"

USING_NS_CC;

using namespace GAMETEMPLATE;


void CGameTemplate::Init()
{
	CCMutableDictionary<UINT, ITemplate*> dummymap;
	_templateList.assign(GAMETEMPLATE::MAX, dummymap);


	CCharacterXMLParser characterParser;
	characterParser.initParsing();
	CAnimationXMLParser animationParser;
	animationParser.initParsing();
}

ITemplate* CGameTemplate::GetTemplate(GAMETEMPLATE::TYPE type, UINT id)
{
	if(type < 0 || type >= GAMETEMPLATE::MAX)
		return NULL;

	auto& val = _templateList[type];
	return val.objectForKey(id);
}

void CGameTemplate::SetTemplate(GAMETEMPLATE::TYPE type, ITemplate* newTemplate)
{
	if(type < 0 || type >= GAMETEMPLATE::MAX)
		return;

	auto& val = _templateList[type];
	val.setObject(newTemplate, newTemplate->id);	
}

CGameTemplate* CGameTemplate::_this = nullptr;

